package app.caihan.scframe.common.loadinghelper

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import app.caihan.scframe.R

/**
 * 默认的界面error效果
 *
 * @author Seven-C
 * @date 2020/8/3
 */
class ErrorAdapter : LoadingHelper.Adapter<ErrorAdapter.ViewHolder>() {

    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
        return ViewHolder(
            inflater.inflate(
                R.layout.scframe_layout_error,
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(holder: ViewHolder) {
        holder.reloadView.setOnClickListener {
            holder.onReloadListener?.let {
                it.onReload()
            }
        }
    }

    class ViewHolder internal constructor(rootView: View) :
        LoadingHelper.ViewHolder(rootView) {
        val reloadView: View = rootView.findViewById(R.id.reload_view)
    }
}